<template>
  <div class="index">
    <div class="header">
      <el-button
        type="primary"
        size="mini"
        @click="
          {
            isShowAddDrawer = true;
          }
        "
        >新增账号</el-button
      >
    </div>
    <div class="tabel">
      <el-table
        :data="tableData"
        border
        header-row-class-name="my-tabel-header"
        :header-row-style="{ height: 50 + 'px' }"
        :row-style="{ height: 50 + 'px' }"
        :cell-style="{ padding: 0 + 'px' }"
        stripe
        style="width: 100%"
      >
        <el-table-column prop="complanyName" label="账号"> </el-table-column>
        <el-table-column prop="name" label="状态"> </el-table-column>
        <el-table-column prop="address" label="操作">
          <template #default="scope">
            <el-button @click="handleUpdate(scope.row)" type="text" size="small"
              >修改密码</el-button
            >
            <el-button @click="handleFrozen(scope.row)" type="text" size="small"
              >冻结账号</el-button
            >
            <el-button @click="handleThaw(scope.row)" type="text" size="small"
              >解冻账号</el-button
            >
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div class="my-dialog">
      <el-dialog title="新增账号" v-model="isShowAddDrawer" width="500px">
        <div>
          <div class="each-d">
            <label><span>*</span>账号：</label>
            <el-input
              v-model="account.userName"
              placeholder="请输入账号"
            ></el-input>
          </div>
          <div class="each-d">
            <label><span>*</span>密码：</label>
            <el-input
              v-model="account.password"
              placeholder="请输入密码"
            ></el-input>
          </div>
          <div class="each-d">
            <label><span>*</span>确认密码：</label>
            <el-input
              v-model="account.rePassword"
              placeholder="请再次输入密码"
            ></el-input>
          </div>
        </div>
        <template #footer>
          <span class="dialog-footer">
            <el-button @click="dialogVisible = false" size="mini"
              >取 消</el-button
            >
            <el-button type="primary" @click="onSave" size="mini"
              >确 定</el-button
            >
          </span>
        </template>
      </el-dialog>
    </div>
    <div class="my-dialog">
      <el-dialog title="修改密码" v-model="isShowUpdatePassword" width="500px">
        <div>
          <div class="each-d">
            <label><span>*</span>新密码：</label>
            <el-input
              v-model="account.password"
              placeholder="请输入密码"
            ></el-input>
          </div>
          <div class="each-d">
            <label><span>*</span>确认新密码：</label>
            <el-input
              v-model="account.rePassword"
              placeholder="请再次输入密码"
            ></el-input>
          </div>
        </div>
        <template #footer>
          <span class="dialog-footer">
            <el-button @click="isShowUpdatePassword = false" size="mini"
              >取 消</el-button
            >
            <el-button type="primary" @click="onSave" size="mini"
              >确 定</el-button
            >
          </span>
        </template>
      </el-dialog>
    </div>
  </div>
</template>

<script lang="ts">
import { defineComponent } from "vue";
export default defineComponent({
  name: "Home",
  data() {
    return {
      title: "新增客户",
      isShowAddDrawer: false,
      isShowUpdatePassword: false,
      account: {
        userName: "", //账号
        password: "", //密码
        rePassword: "", //确认密码
      },
      tableData: [
        {
          name: "张三",
          phone: "15333333333",
          stage: "预成交",
          complanyName: "XXX科技有限公司",
          classification: "100间",
          creater: "李四",
          craetTime: "王五",
        },
      ],
    };
  },
  methods: {
    //修改密码
    handleUpdate(row: any): void {
      var _this = this as any;
      _this.isShowUpdatePassword = true;
    },
    //冻结账号
    handleFrozen(row: any): void {
      var _this = this as any;
      _this
        .$confirm("确定要冻结此账号吗?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
        .then(() => {
          _this.$message({
            type: "success",
            message: "删除成功!",
          });
        })
        .catch(() => {
          _this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    //解冻账号
    handleThaw(row: any): void {
      var _this = this as any;
      _this
        .$confirm("确定要解冻此账号吗?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
        .then(() => {
          _this.$message({
            type: "success",
            message: "删除成功!",
          });
        })
        .catch(() => {
          _this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    //选中表格项
    handleSelectionChange(data: any) {
      console.log(data);
    },
    showAdd() {
      this.isShowAddDrawer = true;
    },
    //保存新增客户
    onSave() {},
  },
});
</script>
<style lang="less" scoped>
.index {
  padding: 30px;
  .header {
    min-height: 50px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
    .seach {
      flex: 1;
      display: flex;
      height: 50px;
      align-items: center;
      .e-seach {
        display: flex;
        align-items: center;
        margin-left: 5px;
        label {
          flex-shrink: 0;
          width: 80px;
          font-size: 14px;
        }
        .e-seach-d {
          width: 180px;
        }
        /deep/.el-select {
          width: 300px;
        }
      }
      .e-seach1 {
        /deep/.el-select {
          width: 160px;
        }
      }
    }
  }
  .tabel {
    /deep/.my-tabel-header {
      > th {
        background: #f4f4f4;
        > .cell {
          font-weight: bold;
          color: #000;
        }
      }
    }
  }
}
.my-dialog {
  /deep/.el-dialog__header {
    padding: 10px 20px;
    background: #eeecec;
    font-weight: 600;
    color: #000;
  }
  /deep/.el-dialog .el-dialog__header .el-dialog__title {
    font-size: 14px;
  }
  /deep/.el-dialog__headerbtn {
    top: 12px;
  }
  /deep/.el-dialog__footer {
    border-top: none;
  }
}
.each-d {
  display: flex;
  align-items: center;
  margin-bottom: 20px;
  &:last-child {
    margin-bottom: 0;
  }
  /deep/.el-select {
    width: 100%;
  }
  /deep/.el-cascader--small {
    width: 100%;
  }
  label {
    text-align: right;
    width: 100px;
    flex-shrink: 0;
    margin-right: 30px;
    span {
      color: #fd192a;
    }
  }
  .record {
    flex: 1;
    border: 1px solid #f5f5f5;
    border-radius: 4px;
    padding: 10px;
    max-height: 500px;
    overflow-y: auto;
    .e-record {
      > p {
        line-height: 20px;
      }
    }
  }
}
/deep/.el-radio.is-bordered + .el-radio.is-bordered {
  margin-left: 0;
}
.radio {
  margin-top: 20px;
  .e-radio {
    padding: 5px 10px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 14px;
    &:hover {
      color: #b53434;
    }
  }
  .active {
    background: #b53434;
    color: #fff;
    &:hover {
      color: #fff;
    }
  }
}
.next {
  margin-top: 20px;
}
.time {
  margin-top: 20px;
}
</style>